//读取子模块
const modules = import.meta.glob('../routes/**/*.ts', { eager: true });

//项目合并并排序
const items: any[] = Object.keys(modules).
reduce((list: any[], key: string): any[] => {
    const mod = (<any>modules[key]).default ?? {};
    const modList = Array.isArray(mod) ? [...mod] : [mod];
    return [...list, ...modList];
}, []);

//执行排序(防止主页配置无效)
items.sort((a: any, b: any): number => {
    if(a.path === undefined)
        return 1;
    if(b.path === undefined)
        return -1;
    return a.path.length - b.path.length;
})

//返回结果集合
export default items;